<?php
class Answer{
	
	public function __construct( &$alt_sql = false){
		global $sql;
		if ($alt_sql==false){
			$this->sql=$sql;
		} else {
			$this->sql=&$alt_sql;
		}	
	}
	
	//set feedback
	public static function setFeedback( $sql, $feedback, $points, $answerId ) {
		$answerId = $answerId;
		$feedback = mysql_escape_string($feedback);
		$points = $points; 
		
		//sends query
		$query = "UPDATE lahendus l SET l.tagasiside = '".$feedback."',
		 l.punktid ='".$points."' 
			WHERE l.idlahendus = '".$answerId."' LIMIT 1";
		
		$sql->query($query);
		if( $sql->affectedRows() == 1 ) {
			return true;
		}
		return false;
		
	}
	
}
?>